package com.newtouch.bxzs.enterprise.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.newtouch.bxzs.common.base.model.PersonalCustomerGroupMap;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 分组客户关联表Mapper层
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2020/12/28 15:19</td>
 * <td>yuanjie</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author yuanjie
 * @version 1.0.0
 * @since 1.0.0
 */
@Mapper
public interface PersonalCustomerGroupMapMapper extends BaseMapper<PersonalCustomerGroupMap> {

    @Insert("<script>" +
            "INSERT INTO ASSISTANT_CUSTOMER_GROUP_MAP (CUSTOMER_GROUP_MAP_ID, GROUP_ID, CUSTOMER_ID, CREATE_USER_ID, CREATE_TIME, UPDATE_USER_ID, UPDATE_TIME ) " +
            "VALUES " +
            "<foreach collection='list' item='item' index='index' separator=','>" +
            "(replace(uuid(),'-',''), #{item.groupId}, #{item.customerId}, #{item.createUserId}, #{item.createTime}, #{item.updateUserId}, #{item.updateTime})" +
            "</foreach>" +
            "</script>")
    void insertBach(@Param("list") List<PersonalCustomerGroupMap> list);
}
